package com.fastjrun.snowy.codeg.generator;

import com.fastjrun.snowy.codeg.generator.method.SnowyHTTPMethodGenerator;
import com.fastjrun.codeg.generator.BaseHTTPGenerator;
import com.fastjrun.codeg.generator.method.BaseControllerMethodGenerator;
import com.fastjrun.codeg.generator.method.BaseHTTPMethodGenerator;
import com.fastjrun.codeg.generator.method.BaseServiceMethodGenerator;
import com.fastjrun.codeg.processor.BaseRequestProcessor;
import com.fastjrun.codeg.processor.BaseResponseProcessor;
import com.fastjrun.codeg.processor.DefaultExchangeProcessor;
import com.fastjrun.snowy.codeg.generator.processor.SnowyRequestProcessor;
import com.fastjrun.snowy.codeg.generator.processor.SnowyResponseProcessor;

public class SnowyHTTPGenerator extends BaseHTTPGenerator {
  @Override
  public BaseControllerMethodGenerator prepareBaseControllerMethodGenerator(
      BaseServiceMethodGenerator serviceMethodGenerator) {
    BaseHTTPMethodGenerator baseHTTPMethodGenerator = new SnowyHTTPMethodGenerator();
    baseHTTPMethodGenerator.setPackageNamePrefix(this.packageNamePrefix);
    baseHTTPMethodGenerator.setMock(this.isMock());
    baseHTTPMethodGenerator.setSwaggerVersion(this.swaggerVersion);
    baseHTTPMethodGenerator.setServiceMethodGenerator(serviceMethodGenerator);
    baseHTTPMethodGenerator.setBaseControllerGenerator(this);
    BaseRequestProcessor baseRequestProcessor = new SnowyRequestProcessor();
    BaseResponseProcessor baseResponseProcessor = new SnowyResponseProcessor();
    DefaultExchangeProcessor<SnowyRequestProcessor, SnowyResponseProcessor>
        exchangeProcessor =
            new DefaultExchangeProcessor(baseRequestProcessor, baseResponseProcessor);
    exchangeProcessor.doParse(serviceMethodGenerator, this.packageNamePrefix);
    baseHTTPMethodGenerator.setExchangeProcessor(exchangeProcessor);
    return baseHTTPMethodGenerator;
  }
}
